package com.magina.mq.rabbit.exchange.direct;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
/**
 * 文件名称：InfoReceiver</br>
 * 初始作者： Magina.Hu</br>
 * 创建日期： 2019/5/10</br>
 * 功能说明： direct类型的Exchange路由规则也很简单，它会把消息路由到那些binding key与routing key完全匹配的Queue中。 <br/>
 * =================================================<br/>
 * 修改记录：<br/>
 * 修改作者 日期 修改内容<br/>
 * ================================================<br/>
 * Copyright (c) 2019-2020 .All rights reserved.<br/>
 */
@Component
@Slf4j
@RabbitListener(
        bindings=@QueueBinding(
                value = @Queue(value = "${rab.cass.config.quene.info}",autoDelete="true"),
                exchange =@Exchange(value = "${rab.cass.config.exchange}",type =ExchangeTypes.DIRECT),
                key = "${rab.cass.config.quene.info.routing.key}"
        )
)
public class InfoReceiver {
    @Value("${rab.cass.config.quene.info}")
    private String infoQueueName;

    @RabbitHandler
    public void process(String msg){
        String resultStr  = "RabbitMq:"+infoQueueName+" consumer 收到一条信息: " + msg;
        System.out.println( resultStr);
    }
}
